package masterPackage;

import lejos.nxt.*;
import lejos.robotics.navigation.Pilot;
import lejos.robotics.navigation.TachoPilot;
import masterPackage.masterClass.*;

public class masterClass {
	
	private Pilot pilot;
	private Muurvolger mv;
	private BarCodeLezer bcl;
	private boolean rechtDoor;
	private int distance;
	private int richting;


	

	public static void main(String[] args)
	{
	    masterClass mc = new masterClass();
	    mc.pilot = new TachoPilot(5.52012f, 11.14f, Motor.A, Motor.C, true);
	    
	    mc.initializeRobot();
	    mc.controlRobot();
	    
	}
	
	private void initializeRobot(){
		//init barcodelezer
		bcl = new BarCodeLezer();
		Thread bclThread = new Thread(bcl);
		bclThread.run();
		
		mv = new MuurVolger();
		
	}
	
	private void controlRobot() {
		while (true) {
			while(rechtdoor == true) {		// zolang er geen barcode gedetecteerd wordt die zegt dat we moeten draaien, rijden we rechtdoor mbv muurvolger
				mv.run();
			}
			
			barcodeGelezen(paneel);
		}
	}
	
	private void barcodeGelezen(Paneel p) {

	}

	public int getDistance() {
		return distance;
	}
	
	protected void setDistance(int distance) {
		this.distance = distance;
	}
	
	public int getRichting() {
		return richting;
	}
	
	protected void setRichting(int richting) {
		this.richting = richting;
	}
	
	
	
	class State{
		public float afstand;
		public boolean interrupt;
		public Paneel paneel;
		
		public boolean equals(State oldState){
			return oldState.afstand == this.afstand && oldState.interrupt == this.interrupt && oldState.paneel == this.paneel;
		}
		
		public State(float afstand, boolean interrupt, Paneel paneel){
			this.afstand = afstand;
			this.interrupt = interrupt;
			this.paneel = paneel;
		}
	}
	
	public enum Paneel{LINKS, RECHTS, RECHTDOOR}
	

	class DistanceSensor implements Runnable{

		private float distance;
		@Override
		public void run() {
			// TODO Auto-generated method stub
			
		}
		
		public float getDistance(){
			return this.distance;
		}
	}
	
	class LijnDetectie implements Runnable{

		private boolean lijnDetected;
		@Override
		public void run() {
			// TODO Auto-generated method stub
			
		}
		
		public boolean isDetected(){
			return this.lijnDetected;
		}
	}
	
	class BarCodeLezer implements Runnable{

		
		private Paneel paneel;
		private int panelCount;
		@Override
		public void run() {
			// TODO Auto-generated method stub
			while(true){
				//run barcodelezer
				//als nieuwe barcode panelCount++ en paneel 
			}
		}
		
		public Paneel getPaneel(){
			return this.paneel;
		}
		
		public int getPanelCnt(){
			return this.panelCount;
		}
	}
	
	
		

}
